package core.ui.demo;

import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

/**
 * @author 李瑜
 * @since JavaFX 8.0
 */
public class Demo2 extends Application
{
	/**
	 * @param stage
	 *            舞台
	 */
	public void start(Stage stage) throws Exception
	{
		initView(stage);
		initMedia();
	}
	private void initMedia()
	{
		// String str =
		// "http://zhangmenshiting.baidu.com/data2/music/38367463/2351521399474861128.mp3?xcode=87e980290f4275e87b707528504ef7d799a1f4b22fcad2a3";
		// Media media = new Media(str);
		// MediaPlayer player = new MediaPlayer(media);
		// player.setAutoPlay(true);
		// player.play();
	}
	private void initView(Stage stage)
	{
		Label label = new Label("标签"); // 标签
		Button button = new Button("按钮");
		CheckBox checkBox = new CheckBox("复选按钮");
		ColorPicker colorPicker = new ColorPicker();
		ComboBox<String> comboBox = new ComboBox<String>();
		Hyperlink hyperlink = new Hyperlink("www.JavaFX.com");
		PasswordField passwordField = new PasswordField();
		ProgressBar progressBar = new ProgressBar(0.5);
		RadioButton radioButton = new RadioButton("单选按钮");
		Separator separator = new Separator();
		Slider slider = new Slider();
		TextArea textArea = new TextArea("文本区域");
		TextField textField = new TextField("文本字段");
		ToggleButton toggleButton = new ToggleButton("开关按钮");

		FlowPane flow = new FlowPane();// 流式布局
		ObservableList<Node> list = flow.getChildren();
		list.add(label);
		list.add(button);
		list.add(checkBox);
		list.add(colorPicker);
		list.add(comboBox);
		list.add(hyperlink);
		list.add(passwordField);
		list.add(progressBar);
		list.add(radioButton);
		list.add(separator);
		list.add(slider);
		list.add(textArea);
		list.add(textField);
		list.add(toggleButton);

		Scene scene = new Scene(flow);// 幕布

		stage.setScene(scene);

		stage.setTitle("JavaFX");
		stage.show();
	}
	
	public static void main(String[] args) {
		launch();
	}
}
